/*
 * @Author: your name
 * @Date: 2021-04-06 20:36:02
 * @LastEditTime: 2021-04-12 09:47:56
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \shop\training-group-5-warehouse\dianshang\src\api\group\index.js
 */
//拼团
import axios from '../../utils/request'
import baseUrl from '../../utils/baseUrl'

//拼团数据
function group() {
    // 返回值是Promise;
    return axios.get(baseUrl.url + '/api/fandgrouplist');
}

//查询拼团商品
function groupItem(shopId) {
    // 返回值是Promise;
    return axios.post(baseUrl.url + '/api/fandgroupshop', { shopId });
}

//推荐数据
function recommends() {
    // 返回值是Promise;
    return axios.get(baseUrl.url + '/api/recommends');
}

//获取拼团地址
function fandcitylist() {
    // 返回值是Promise;
    return axios.get(baseUrl.url + '/api/fandcitylist');
}

//添加拼团地址
function addcitylist({ name, phoneNumber, region, detailed }) {
    // 返回值是Promise;
    return axios.post(baseUrl.url + '/api/addcitylist', { name, phoneNumber, region, detailed });
}

//删除拼团地址
function deletecitylist(id) {
    // 返回值是Promise;
    return axios.delete(baseUrl.url + '/api/deletecitylist', { data: { id } });
}

//编辑地址
function updatecitylist({ name, phoneNumber, region, detailed }, id) {
    // 返回值是Promise;
    return axios.put(baseUrl.url + '/api/updatecitylist', { id, name, phoneNumber, region, detailed });
}

//添加拼团历史记录
function addGroupRecords({ shopId, userImgUrl, username }) {
    // 返回值是Promise;
    return axios.post(baseUrl.url + '/api/addgrouprecords', { shopId, userImgUrl, username });
}

//查找拼团历史记录
function fandGroupRecordsList(shopId) {
    // 返回值是Promise;
    return axios.get(baseUrl.url + '/api/fandgrouprecordslist', { params: { shopId } });
}

//添加拼团详情商品
function insertGroupdetails({ userId, groupNumber, groupImgUrl, time, already, grouprecordsNum }) {
    // 返回值是Promise;
    return axios.post(baseUrl.url + '/api/insertgroupdetails', { userId, groupNumber, groupImgUrl, time, already, grouprecordsNum });
}

//查找拼团详情商品
function fandGroupdetails(userId) {
    // 返回值是Promise;
    return axios.get(baseUrl.url + '/api/fandgroupdetails', { params: { userId } });
}

export default {
    group,
    recommends,
    groupItem,
    addcitylist,
    fandcitylist,
    deletecitylist,
    updatecitylist,
    addGroupRecords,
    fandGroupRecordsList,
    insertGroupdetails,
    fandGroupdetails
}